//
//  MineViewController.m
//  mixApp
//
//  Created by fantasy on 2021/6/28.
//

#import "MineViewController.h"
#import <FlutterPluginRegistrant/GeneratedPluginRegistrant.h>
#import "AppDelegate.h"
@interface MineViewController ()

@end

@implementation MineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIButton * nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    nextBtn.frame = CGRectMake(100, 200, 200, 100);
    nextBtn.layer.cornerRadius = 20.0;
    nextBtn.clipsToBounds = YES;
    [nextBtn setTitle:@"next flutter Page" forState:UIControlStateNormal];
    [nextBtn.titleLabel setFont:[UIFont systemFontOfSize:15.0]];
    nextBtn.backgroundColor = [UIColor brownColor];
    [nextBtn addTarget:self action:@selector(onTap) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:nextBtn];
    
    UIButton * backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    backBtn.frame = CGRectMake(100, 400, 200, 100);
    backBtn.layer.cornerRadius = 20.0;
    backBtn.clipsToBounds = YES;
    [backBtn setTitle:@"Native First Page" forState:UIControlStateNormal];
    [backBtn.titleLabel setFont:[UIFont systemFontOfSize:15.0]];
    backBtn.backgroundColor = [UIColor brownColor];
    [backBtn addTarget:self action:@selector(onBack) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:backBtn];
    // Do any additional setup after loading the view.
}
-(void)onBack{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}
-(void)onTap{
    FlutterEngine * fluEng = ((AppDelegate *)UIApplication.sharedApplication.delegate).flutterEdgine;
    FlutterViewController * fluvc = [[FlutterViewController alloc]initWithEngine:fluEng nibName:nil bundle:nil];
    fluvc.modalPresentationStyle = UIModalPresentationFullScreen;
    [self presentViewController:fluvc animated:YES completion:^{
        
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
